﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Position.aspx.cs" Inherits="manager_dept_Position" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <title>岗位管理</title>
    <!-- iCheck -->
    <link href="/reference/plugins/iCheck/all.css" rel="stylesheet" />
    <!-- select2 -->
    <link href="/reference/plugins/select2/select2.min.css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">
    <section class="content-header">
        <h1>岗位管理
            <small>部门岗位</small>
        </h1>
        <ol class="breadcrumb">
            <li><a><i class="fa fa-dashboard"></i>主页</a></li>
            <li><a href="userManager.aspx">部门岗位</a></li>
            <li class="active">岗位管理</li>
        </ol>
    </section>

    <section class="content">

        <div class="box box-primary">
            <div class="box-header with-border">
                <div>
                    <div class="box-tools pull-left">
                        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#userManager" data-action="add">添加岗位</button>
                    </div>

                </div>
            </div>
            <div class="box-body">
                <ul class="nav nav-tabs" role="tablist">
                    <%=Html_Dept %>
                </ul>
                <div class="tab-content">
                    <%=Html_Dept_Detail %>
                </div>
            </div>
            <div class="modal fade" id="userManager" role="dialog" aria-labelledby="userManagerLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="userManagerLabel"></h4>
                        </div>
                        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <div style="display: none">
                                    <asp:Button ID="btnGet" runat="server" Text="Get" OnClick="btnGet_Click" />
                                </div>
                                <div class="modal-body">
                                    <asp:HiddenField ID="hidBID" runat="server" />
                                    <table class="table table-bordered">
                                        <tr>
                                            <td class="col-sm-2">名称</td>
                                            <td>
                                                <asp:TextBox ID="txtMc" CssClass="form-control" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">部门</td>
                                            <td>
                                                <asp:TextBox ID="txtDeptMc" CssClass="form-control" runat="server">办公室</asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">上级</td>
                                            <td>
                                                <asp:DropDownList ID="dllParent" CssClass="form-control" runat="server">
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">类型</td>
                                            <td>
                                                <asp:DropDownList ID="dllType" CssClass="form-control" runat="server">
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">当前在岗</td>
                                            <td>
                                                <asp:DropDownList ID="dllUser" CssClass="form-control" runat="server">
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">自动完成</td>
                                            <td>
                                                <asp:DropDownList ID="ddlIsZdwc" CssClass="form-control" runat="server">
                                                    <asp:ListItem Value="1">是</asp:ListItem>
                                                    <asp:ListItem Value="0" Selected="True">否</asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="col-sm-2">是否可用</td>
                                            <td>
                                                <asp:DropDownList ID="ddlIsUsing" CssClass="form-control" runat="server">
                                                    <asp:ListItem Value="1">是</asp:ListItem>
                                                    <asp:ListItem Value="0">否</asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <asp:Button ID="btnSave" runat="server" Text="确定" CssClass="btn btn-primary" OnClick="btnSave_Click" />
                            <asp:Button ID="btnUpdate" runat="server" Text="修改" CssClass="btn btn-primary" OnClick="btnUpdate_Click" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <div style="display: none">
        <input type="text" id="dept_id" runat="server" />
        <input type="text" id="dept_id_now" value="1" runat="server" />
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptPlaceHolder" runat="Server">
    <script type="text/javascript">
        $('#userManager').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget)

            var action = button.data('action');
            if (action == "add") {
                $("#userManagerLabel").text("添加岗位");
                $("#ContentPlaceHolder_btnSave").css("display", "");
                $("#ContentPlaceHolder_btnUpdate").css("display", "none");

                $("#ContentPlaceHolder_txtMc").val("");
                $("#ContentPlaceHolder_ddlIsUsing").val("1");

                $("#ContentPlaceHolder_hidBID").val("");
                $("#ContentPlaceHolder_btnGet").click();

            }
            else if (action == "update") {
                $("#userManagerLabel").text("修改岗位");
                $("#ContentPlaceHolder_btnSave").css("display", "none");
                $("#ContentPlaceHolder_btnUpdate").css("display", "");

                var browserID = button.data('bid');
                $("#ContentPlaceHolder_hidBID").val(browserID);
                $("#ContentPlaceHolder_btnGet").click();
            }
        })

        $(document).ready(function () {
            var type = $("#ContentPlaceHolder_dept_id").val();
            var arr_dept = type.split("|");
            for (var i = 0; i < arr_dept.length; i++) {
                $("#table_" + arr_dept[i]).DataTable(
                               {
                                   "columnDefs": [
                                       { "targets": [0], "visible": false }
                                   ],
                                   "autoWidth": true,
                                   "ordering": false,
                                   "scroll": true,
                                   "language": {
                                       "url": "/reference/plugins/datatables/Chinese.json"
                                   }
                               });
            }
        });

        function SetDept(id, mc) {
            $("#ContentPlaceHolder_dept_id_now").val(id);
            $("#ContentPlaceHolder_txtDeptMc").val(mc);
        }

    </script>
</asp:Content>

